import { RouteRecordRaw } from 'vue-router'
import { HOME_URL, LOGIN_URL } from '@/core/config'
import Layout from '@/core/layout/index.vue'

/**
 * LayoutRouter (布局路由)
 */
export const layoutRouter: RouteRecordRaw[] = [
  {
    // 登录成功以后展示数据的路由[一级路由，可以将子路由放置Main模块中(核心)]
    path: '/', // 路由访问路径[唯一]
    name: 'layout', // 命名路由[唯一]
    component: Layout, // 登录进入这个页面，这个页面是整个布局
    redirect: HOME_URL, // path路径，<router-link name="/404"> 也是使用path进行跳转
    children: [
      {
        path: HOME_URL, // [唯一]
        component: () => import('@/app/views/home/index.vue'),
        meta: {
          title: '欢迎', // 标题
          icon: 'HomeFilled', // 图标
          isHide: '0', // 代表路由在菜单中是否隐藏，是否隐藏[1隐藏，0显示]
          isLink: '', // 是否外链[有值则是外链]
          isKeepAlive: '0', // 是否缓存路由数据[1是，0否]
          isFull: '0', // 是否缓存全屏[1是，0否]
          isAffix: '0', // 是否缓存固定路由[1是，0否]
        },
      },
    ],
  },
  {
    path: LOGIN_URL,
    name: 'login',
    component: () => import('@/app/views/login/index.vue'),
    meta: {
      title: '登录',
    },
  },
]

/**
 * errorRouter (错误页面路由)
 */
export const errorRouter = [
  {
    path: '/403',
    name: '403',
    component: () => import('@/app/views/error/403.vue'),
    meta: {
      title: '403页面',
      icon: 'QuestionFilled',
      isHide: '0',
      isLink: '0',
      isKeepAlive: '0',
      isFull: '0',
      isAffix: '0',
    },
  },
  {
    path: '/404',
    name: '404',
    component: () => import('@/app/views/error/404.vue'),
    meta: {
      title: '404页面',
      icon: 'CircleCloseFilled',
      isHide: '0',
      isLink: '0',
      isKeepAlive: '0',
      isFull: '0',
      isAffix: '0',
    },
  },
  {
    path: '/500',
    name: '500',
    component: () => import('@/app/views/error/500.vue'),
    meta: {
      title: '500页面',
      icon: 'WarningFilled',
      isHide: '0',
      isLink: '0',
      isKeepAlive: '0',
      isFull: '0',
      isAffix: '0',
    },
  },
  // 找不到path将跳转404页面
  {
    path: '/:pathMatch(.*)*',
    component: () => import('@/app/views/error/404.vue'),
  },
]
